package bean;

import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.JTextField;

public class Cronometro extends JTextField {
	int seg =0;
	boolean suspendido = false;
	private Thread hilo;
	public Cronometro() {
		super();
		hilo = new Thread(){
			public void run(){
				try{
					while(true){
						
						Thread.sleep(1000);
						
						setText(String.valueOf(seg++));
						
						}
					} 
				catch (java.lang.InterruptedException ie) { System.out.println(ie.getMessage());
				}
				}
			};
	}
	
	//@SuppressWarnings("deprecation")
	public void empezar() {
		//if(!suspendido){
			hilo.start();
			//lblStatus.setText("Estado: Iniciado");
		//}
		/*else
		{
			hilo.resume();
			suspendido = false;
			//lblStatus.setText("Estado: Resumido");
		}*/
	}
		
	public void detenerse() {
		hilo.stop();
	}
	public void resumir(){
		hilo.resume();
	}
}

   
